CC = g++
ARGS = -Wall -I/usr/local/mysql-current/include  -L/usr/local/mysql-current/lib/mysql -lmysqlclient -ldl

all: Server Client

Server: Server.o 	TCPSocket.o 	Utilities.o 	ApplicationLayer.o 	DataLinkLayer.o 	PhysicalLayer.o	Client.o    DBAccess.o    					
	$(CC) $(ARGS) -o Server Server.o TCPSocket.o Utilities.o ApplicationLayer.o DataLinkLayer.o PhysicalLayer.o Client.o DBAccess.o -lpthread -lmysqlclient

Server.o: Server.cpp
	$(CC) $(ARGS) -c Server.cpp  
	
DBAccess.o: DBAccess.cpp DBAccess.h
	$(CC) $(ARGS) -c DBAccess.cpp DBAccess.h -I/usr/include/mysql  -L/usr/lib/mysql -lmysqlclient -lz

TCPSocket.o: TCPSocket.cpp TCPSocket.h	
	$(CC) $(ARGS) -c -fpermissive TCPSocket.cpp TCPSocket.h 
	
ApplicationLayer.o: ApplicationLayer.cpp ApplicationLayer.h	
	$(CC) $(ARGS) -c ApplicationLayer.cpp ApplicationLayer.h
	
DataLinkLayer.o: DataLinkLayer.cpp DataLinkLayer.h	
	$(CC) $(ARGS) -c DataLinkLayer.cpp DataLinkLayer.h
	

PhysicalLayer.o: PhysicalLayer.cpp PhysicalLayer.h	
	$(CC) $(ARGS) -c PhysicalLayer.cpp PhysicalLayer.h
	
Client.o: Client.cpp  Client.h
	$(CC) $(ARGS) -c Client.cpp  Client.h
	
	
Client: ClientLauncher.o    Client.o 	TCPSocket.o 	Utilities.o 	ApplicationLayer.o 	DataLinkLayer.o 	PhysicalLayer.o	DBAccess.o
	$(CC) $(ARGS) -o Client ClientLauncher.o Client.o TCPSocket.o Utilities.o ApplicationLayer.o DataLinkLayer.o PhysicalLayer.o DBAccess.o -lpthread -lmysqlclient

ClientLauncher.o: ClientLauncher.cpp
	$(CC) $(ARGS) -c ClientLauncher.cpp	

clean:
	rm -f *.o  Server Client  *~
